using System.Text;

namespace OracleInternal.SqlAndPlsqlParser.LocalParsing
{
	internal class OracleLpWithClause : OracleLpStatementElement, IOracleLpNamedObjectContainer
	{
		protected OracleLpPlsqlDeclarations m_vPlsqlDeclarations;

		protected OracleLpSubqueryFactoringClause m_vSubqueryFactoringClause;

		internal override OracleLpStatementElementType ElementType => OracleLpStatementElementType.WithClause;

		public OracleLpPlsqlDeclarations PlsqlDeclarations
		{
			get
			{
				return m_vPlsqlDeclarations;
			}
			set
			{
				m_vPlsqlDeclarations = value;
			}
		}

		public OracleLpSubqueryFactoringClause SubqueryFactoringClause
		{
			get
			{
				return m_vSubqueryFactoringClause;
			}
			set
			{
				m_vSubqueryFactoringClause = value;
				if (m_vSubqueryFactoringClause != null)
				{
					m_vSubqueryFactoringClause.Parent = this;
				}
			}
		}

		public OracleLpWithClause(OracleLpStatementElement parent)
			: base(parent)
		{
		}

		public void RetrieveNamedObjectReferences(OracleLpStatement statement)
		{
			if (m_vSubqueryFactoringClause != null)
			{
				m_vSubqueryFactoringClause.RetrieveNamedObjectReferences(statement);
			}
		}

		internal override void ToString(StringBuilder sb)
		{
			string depthIndent = base.DepthIndent;
			sb.Append(depthIndent);
			sb.Append("With clause:\n");
			if (m_vSubqueryFactoringClause != null)
			{
				m_vSubqueryFactoringClause.ToString(sb);
			}
		}
	}
}
